#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")"

if [ -d "venv" ] && [ -f "venv/bin/activate" ]; then
  # shellcheck disable=SC1091
  source venv/bin/activate
fi

mkdir -p logs

nohup python runbot.py --exchange edgex --edgex-close-all-positions \
  >> logs/position_close.out 2>&1 &

echo $! > position_close.pid
echo "Started close-all-positions in background (PID $(cat position_close.pid)). Logs: logs/position_close.out"


